import { ChangeDetectionStrategy, Component, Input, OnInit, SimpleChanges } from '@angular/core';

@Component({
  selector: 'app-wy-slider-track',
  templateUrl: './wy-slider-track.component.html',
  styleUrls: ['./wy-slider-track.component.less'],
  changeDetection:ChangeDetectionStrategy.OnPush

})
export class WySliderTrackComponent implements OnInit {

  @Input() wyVertical = false;//默认水平
  @Input() wyLength?: number;
  @Input() wyBuffer = false;

  style:any;

  constructor() { }

  ngOnInit(): void {
  }

  ngOnChanges(changes: SimpleChanges): void {
    // wyLength不断改变，
    if (changes.wyLength) {
      // 垂直
      if (this.wyVertical) {
        this.style.height = this.wyLength + '%';
        this.style.left = null;
        this.style.width = null;
      } else {
        // 水平
        this.style.width = this.wyLength + '%';
        this.style.bottom = null;
        this.style.height = null;
      }
    }
  }

}
